package view;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Shell;

import control.Storage;

import view.resources.Images;

public class MemoryCard {

	private boolean bActive = false;

	public MemoryCard(final Shell shell) {
		final Button button = new Button(shell, SWT.PUSH);
		button.setSize(200, 200);
		button.setImage(Images.DEFAULT.createImage());
		button.addSelectionListener(new SelectionListener() {

			@Override
			public void widgetSelected(SelectionEvent e) {
				if (bActive) {
					bActive = false;
					button.setImage(Images.DEFAULT.createImage());
				} else {
					bActive = true;
					Image img = Storage.getImageList().get(5);
					Image i = img;
					
					i =  new Image(shell.getDisplay(),i.getImageData().scaledTo(button.getSize().x, button.getSize().y));
					button.setImage(i);
				}

			}

			@Override
			public void widgetDefaultSelected(SelectionEvent e) {
				// TODO Auto-generated method stub

			}
		});

	}

}
